﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Text.RegularExpressions;

namespace _7DaysToDieTools.Class
{
    public class LangItem
    {
        public string Key { get; set; }
        public string Source { get; set; }
        public string Context { get; set; }
        public string Changes { get; set; }
        public string English { get; set; }
        public string French { get; set; }
        public string German { get; set; }
        public string Klingon { get; set; }
        public string Spanish { get; set; }

        public string ToStr()
        {
            StringBuilder sb = new StringBuilder();
            sb.Append(Key).Append(",");
            sb.Append(Source).Append(",");
            sb.Append(Context).Append(",");
            sb.Append(Changes).Append(",");
            if (Regex.Matches(English, ",").Count > 0)
            {
                sb.Append("\"").Append(English).Append("\",");
            }
            else
            {
                sb.Append(English).Append(",");
            }
            if (Regex.Matches(French, ",").Count > 0)
            {
                sb.Append("\"").Append(French).Append("\",");
            }
            else
            {
                sb.Append(French).Append(",");
            }
            if (Regex.Matches(German, ",").Count > 0)
            {
                sb.Append("\"").Append(German).Append("\",");
            }
            else
            {
                sb.Append(German).Append(",");
            }
            if (Regex.Matches(Klingon, ",").Count > 0)
            {
                sb.Append("\"").Append(Klingon).Append("\",");
            }
            else
            {
                sb.Append(Klingon).Append(",");
            }
            if (Regex.Matches(Spanish, ",").Count > 0)
            {
                sb.Append("\"").Append(Spanish).Append("\"");
            }
            else
            {
                sb.Append(Spanish);
            }
            return sb.ToString();
        }

        public static string GetHeader()
        {
            return "Key,Source,Context,Changes,English,French,German,Klingon,Spanish";
        }
    }
}
